package com.example.studentcompetitionplatform.controller;

import com.example.studentcompetitionplatform.controller.dto.PageDto;
import com.example.studentcompetitionplatform.entity.CompetitionArchives;
import com.example.studentcompetitionplatform.entity.Users;
import com.example.studentcompetitionplatform.service.IDangAnService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/dangan")
public class DangAnController {
    @Resource
    private IDangAnService dangAnService;
    //新增
    @PostMapping("/register")
    public Integer register(@RequestBody CompetitionArchives competitionArchives){
        dangAnService.register(competitionArchives);
        return 1;
    }
    //删除
    @PostMapping("/del")
    public Integer delete(@RequestBody CompetitionArchives competitionArchives){
        dangAnService.delete(competitionArchives);
        return 1;
    }
    //编辑
    @PostMapping("/edit")
    public Integer update(@RequestBody Users users){

        return 1;
    }
    //分页数据查询
    @GetMapping("/page")
    public Map<String, Object> findPage(@RequestParam(value = "pageNum") Integer pageNum,
                                        @RequestParam(value = "pageSize") Integer pageSize,
                                        @RequestParam(value = "archiveId",required = false) Integer archiveId,
                                        @RequestParam(value = "competitionId",required = false) Integer competitionId,
                                        @RequestParam(value = "userId",required = false) Integer userId) {
        return dangAnService.page(pageNum,pageSize,archiveId,competitionId,userId);
    }
}
